{extend name='public/base' /}
{block name='content'}
{include file='public/content_header' /}
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <!-- 表单头部 -->
                <div class="box-header with-border">
                    <div class="btn-group">
                        <a class="btn flat btn-sm btn-default BackButton">
                            <i class="fa fa-arrow-left"></i>
                            返回
                        </a>
                    </div>
                </div>
                <!-- 表单 -->
                <form id="dataForm" class="form-horizontal dataForm" action="" method="post" enctype="multipart/form-data">
                    <!-- 表单字段区域 -->
                    <div class="box-body">
                        <div class="form-group">
                            <label for="mid" class="col-sm-2 control-label">商家ID</label>
                            <div class="col-sm-10 col-md-4">
                                <select name="mid" id="mid" class="form-control field-select" data-placeholder="请选择商家id">
                                    <option value="">请选择...</option>
                                    {foreach name="bus" item="vo"}
                                    <option value="{$vo.id}" {if isset($data) && $vo.id == $data.mid} selected {/if}>{$vo.store_name}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="image" class="col-sm-2 control-label">商品主图</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="image" name="image"  placeholder="请上传商品主图" data-initial-preview="{$data.image|default=''}" type="file" class="form-control field-image" >
                            </div>
                        </div>
                        <script>
                            $('#image').fileinput({
                                language: 'zh',
                                overwriteInitial: true,
                                browseLabel: '浏览',
                                initialPreviewAsData: true,
                                dropZoneEnabled: false,
                                showUpload:false,
                                showRemove: false,
                                allowedFileTypes:['image'],
                                maxFileSize:10240,
                            });
                        </script>
                        <div class="form-group">
                            <label for="price" class="col-sm-2 control-label">商品价格</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="price" name="price" value="{$data.price|default='0.00'}" placeholder="请输入价格" type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
                        <!--<script>-->
                            <!--$('#price')-->
                                <!--.bootstrapNumber({-->
                                    <!--upClass: 'success',-->
                                    <!--downClass: 'primary',-->
                                    <!--center: true-->
                                <!--});-->
                        <!--</script>-->
                        <div class="form-group">
                            <label for="keyword" class="col-sm-2 control-label">关键词</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="keyword" name="keyword" value="{$data.keyword|default=''}" placeholder="请输入关键词" type="text" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="address" class="col-sm-2 control-label">发货地址</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="address" name="address" value="{$data.address|default=''}" placeholder="请输入发货地址" type="text" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="url" class="col-sm-2 control-label">商品链接</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="url" name="url" value="{$data.url|default=''}" placeholder="请输入商品链接" type="text" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="order_time" class="col-sm-2 control-label">购买日期</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="order_time" readonly name="order_time" value="{$data.order_time|default=''}" placeholder="请选择购买开始日期" type="text" class="form-control filed-datetime">
                            </div>
                        </div>
                        <script>
                            laydate.render({
                                elem: '#order_time',
                                type: 'datetime',
                            });
                        </script>
                        <div class="form-group">
                            <label for="back_gold" class="col-sm-2 control-label">每单返金币</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="back_gold" name="back_gold" value="{$data.back_gold|default='0.00'}" placeholder="请输入每单返金币" type="text" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="task_num" class="col-sm-2 control-label">单数</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="task_num" name="task_num" value="{$data.task_num|default='0'}" placeholder="请输入单数" type="text" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="require_content" class="col-sm-2 control-label">任务要求</label>
                            <div class="col-sm-10">
                                <script id="require_content" name="require_content" type="text/plain">{$data.require_content|raw|default=''}</script>
                            </div>
                        </div>
                        <script>
                            UE.delEditor('require_content');
                            var UE_require_content = UE.getEditor('require_content',{
                                serverUrl :UEServer
                            });
                        </script>
                        <div class="form-group">
                            <label for="buy_num" class="col-sm-2 control-label">数量</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="buy_num" name="buy_num" value="{$data.buy_num|default='0'}" placeholder="请输入数量" type="text" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="attr_name" class="col-sm-2 control-label">规格</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="attr_name" name="attr_name" value="{$data.attr_name|default=''}" placeholder="请输入规格" type="text" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">
                                状态
                                <!--0 待发布 1进行中 2已结束-->
                            </label>
                            <div class="col-sm-10 col-md-4" style="padding:5px;">&nbsp;
                                <input type="radio" name="status" value="0" {if isset($data) && $data.status==0} checked {/if} />&nbsp;待发布&nbsp;
                                <input type="radio" name="status" value="1" {if isset($data) && $data.status==1} checked {/if} />&nbsp;进行中&nbsp;
                                <input type="radio" name="status" value="2" {if isset($data) && $data.status==2} checked {/if} />&nbsp;已结束&nbsp;
                            </div>
                        </div>
                    </div>
                    <!-- 表单底部 -->
                    <div class="box-footer">
                        {:token()}
                        <div class="col-sm-2">
                        </div>
                        <div class="col-sm-10 col-md-4">
                            {if !isset($data)}
                            <div class="btn-group pull-right">
                                <label class="createContinue">
                                    <input type="checkbox" value="1" id="_create" name="_create"
                                           title="继续添加数据">继续添加</label>
                            </div>
                            {/if}
                            <div class="btn-group">
                                <button type="submit" class="btn flat btn-info dataFormSubmit">
                                    保存
                                </button>
                            </div>
                            <div class="btn-group">
                                <button type="reset" class="btn flat btn-default dataFormReset">
                                    重置
                                </button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</section>
<script>
    /** 表单验证 **/
    $('#dataForm').validate({
        rules: {
            'order_no': {
                required: false,
            },
            'mid': {
                required: true,
            },
            'price': {
                required: true,
            },
            'keyword': {
                required: true,
            },
            'address': {
                required: true,
            },
            'url': {
                required: true,
            },
            'order_time': {
                required: true,
            },
            'back_gold': {
                required: true,
            },
            'task_num': {
                required: true,
            },
            'require_content': {
                required: true,
            },
            'buy_num': {
                required: true,
            },
            'attr_name': {
                required: true,
            },

        },
        messages: {
            'order_no': {
                required: "主订单编号不能为空",
            },
            'mid': {
                required: "商家id不能为空",
            },
            'price': {
                required: "价格不能为空",
            },
            'keyword': {
                required: "关键词不能为空",
            },
            'address': {
                required: "发货地址不能为空",
            },
            'url': {
                required: "商品链接不能为空",
            },
            'order_time': {
                required: "购买开始日期不能为空",
            },
            'back_gold': {
                required: "每单返金币不能为空",
            },
            'task_num': {
                required: "单数不能为空",
            },
            'require_content': {
                required: "任务要求不能为空",
            },
            'buy_num': {
                required: "数量不能为空",
            },
            'attr_name': {
                required: "规格不能为空",
            },

        }
    });
</script>
{/block}